home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++,comp.lang.java
- Path: netcom.com!milod
- From: milod@netcom.com (John DiCamillo)
- Subject: Re: Java: What's the Big Deal?
- Message-ID: <milodDoouru.Dz8@netcom.com>
- Organization: NETCOM On-line Communication Services (408 261-4700 guest)
- References: <milodDoF9JF.K32@netcom.com> <1996Mar20.154600.12011@amc.com> <4iuenj$ng2@decaxp.HARVARD.EDU>
- Date: Fri, 22 Mar 1996 21:38:18 GMT
- Sender: milod@netcom16.netcom.com
-
- robison@mito.harvard.edu (Keith Robison) writes:
- >Curtis Green (curtis@amc.com) wrote:
- >: John DiCamillo (milod@netcom.com) wrote:
- >: : pete@borland.com (Pete Becker) writes:
-
- >: : >>2) No header files => faster compilation
- >: :
- >: : >Nonsense. Header files are simply text that gets included where you want it. If
- >: : >you write the same code without header files it will not magically compile
- >: : >faster.
- >: :
- >: : It's not nonsense. Cascaded #includes result in such a
- >: : drastic inflation of the source text that it makes a measurable
- >: : increase in compilation time.
- >: If you surround your header file with #ifndef .. #endif you should be able
- >: to eliminate your cascaded #include problem
- >: foo.h
- >: #ifndef FOO_H
- >: #define FOO_H
- >: ...
- >: #endif
-
- >I think what the author was referring to was not multiply-including
- >a particular header file (which is generally a compile-time error),
- >but the fact that each header includes other headers which include
- >other headers (etc). This can indeed take a long time with a large
- >header file collection, even if properly defended as above.
-
- Correct, although if you know the guard flags, you can say
-
- #ifndef FOO_H
- #include foo.h
- #endif
-
- at each point where you might want to include foo.h. This way,
- if you've already seen the file, it won't be re-expanded by the
- preprocessor. We used this technique on one large project with
- BC4.5, and it saved us some time.
-
- >What is far more evil is that your namespace depends on this
- >rat's nest of includes, and that the actual pattern of includes
- >depends on the includes. This is one feature I really like about
- >Java -- you are required to explicitly set up your namespace, and
- >therefore the namespace for a given compilation unit can be determined
- >by the text in that source file; no identifiers sneaking in because
- >they were included 10 levels back.
-
- The real point is that since the preprocessor can effectively
- modify the contents of a header file as it is included, the
- compiler must continually re-parse the same header file for
- each source file. In Java, once a module has been compiled
- once, the compiler is done -- from then on it can just re-use
- the .class file for subsequent imports.
-
- --
- ciao,
- milo
- ================================================================
- John DiCamillo Fiery the Angels Fell
- milod@netcom.com Deep thunder rode around their shores
-